package org.yi.fc.validator.admin;

import org.apache.commons.lang.StringUtils;
import org.yi.fc.entity.FFriendLink;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class FriendLinkValidator extends Validator {

	@Override
	protected void validate(Controller controller) {
		StringBuffer sb = new StringBuffer();
		if(StringUtils.isBlank(controller.getPara("keyword"))) {
			sb.append("关键词不能为空!");
		}
		if(StringUtils.isBlank(controller.getPara("url"))) {
			sb.append("链接不能为空!");
		}
		addError("error", sb.toString());
	}

	@Override
	protected void handleError(Controller controller) {
		controller.keepModel(FFriendLink.class);
		
		String actionKey = getActionKey();
		if (actionKey.indexOf("friendlink/add") > 0) {
			controller.render("add.html");
		}
	}

}
